<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>皇上翻牌</title>
</head>
<body>
<div>
		<select name="wife" id="">
			<option value="皇后">皇后</option>
			<option value="皇贵妃" selected="selected">皇贵妃</option>
			<option value="贵妃">贵妃</option>
			<option value="德妃">德妃</option>
			<option value="淑妃">淑妃</option>
			<option value="令妃">令妃</option>
			<option value="熹妃">熹妃</option>
		</select>
		<input type="button" value = "翻牌">
	</div>
	<script>
		var input=document.querySelector('input');
		var select=document.querySelector('select');
		var opts=select.getElementsByTagName('option');
		input.onclick=function(){
			var i=Math.floor(Math.random()*7);
			// alert(i);
			opts[i].selected='selected';
		}
	</script>	
</body>
</html>